#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Intesim Python Script

Window.initCadWindow()
Window.setView('topview')
gl.Parameter('X1', 12.8)
CAD.addParameter('X1')
CAD.recomputeby('X1')
gl.Parameter('X2', 33.4)
CAD.addParameter('X2')
CAD.recomputeby('X2')
gl.Parameter('R1', 8.19)
CAD.addParameter('R1')
CAD.recomputeby('R1')
gl.Parameter('R2', 3.4)
CAD.addParameter('R2')
CAD.recomputeby('R2')
gl.Parameter('R3', 6.0)
CAD.addParameter('R3')
CAD.recomputeby('R3')
gl.Parameter('R4', 2)
CAD.addParameter('R4')
CAD.recomputeby('R4')
gl.Parameter('R5', 6.59)
CAD.addParameter('R5')
CAD.recomputeby('R5')
# 衔铁位置DIST最小值 = 2.1， DIST最大值 = 4.8
gl.Parameter('DIST', 4.5)
CAD.addParameter('DIST')
CAD.recomputeby('DIST')

sketch = CAD.addSketch('sketch')
sketch.setRotation(0, 0, 0, 1)
CAD.getSketch('sketch').addPoint(CAD.Point(10.5, 3.8))
CAD.getSketch('sketch').addPoint(CAD.Point(23.1, 3.8))
CAD.getSketch('sketch').addPoint(CAD.Point(23.1, 38.2))
CAD.getSketch('sketch').addPoint(CAD.Point(10.5, 38.2))
Model.updateSolverList()
Model.updateSolverList()
CAD.recompute()
CAD.getObject('sketch').label = 'coil'
CAD.getSketch('sketch').addLine(start = CAD.Point(10.5, 3.8), end = CAD.Point(23.1, 3.8), construction = False)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.Start, geo_2='vertex1', pos_2=PointPos.Start)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.End, geo_2='vertex2', pos_2=PointPos.Start)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Horizontal, geo_1='line1')
CAD.getSketch('sketch').addLine(start = CAD.Point(23.1, 3.8), end = CAD.Point(23.1, 38.2), construction = False)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Coincident, geo_1='line2', pos_1=PointPos.Start, geo_2='vertex2', pos_2=PointPos.Start)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Coincident, geo_1='line2', pos_1=PointPos.End, geo_2='vertex3', pos_2=PointPos.Start)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Vertical, geo_1='line2')
CAD.getSketch('sketch').addLine(start = CAD.Point(23.1, 38.2), end = CAD.Point(10.5, 38.2), construction = False)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Coincident, geo_1='line3', pos_1=PointPos.Start, geo_2='vertex3', pos_2=PointPos.Start)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Coincident, geo_1='line3', pos_1=PointPos.End, geo_2='vertex4', pos_2=PointPos.Start)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Horizontal, geo_1='line3')
CAD.getSketch('sketch').addLine(start = CAD.Point(10.5, 38.2), end = CAD.Point(10.5, 3.8), construction = False)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Coincident, geo_1='line4', pos_1=PointPos.Start, geo_2='vertex4', pos_2=PointPos.Start)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Coincident, geo_1='line4', pos_1=PointPos.End, geo_2='vertex1', pos_2=PointPos.Start)
CAD.getSketch('sketch').addConstraint(type=ConstraintType.Vertical, geo_1='line4')
CAD.recompute()

sketch = CAD.addSketch('sketch001')
sketch.setRotation(0, 0, 0, 1)
CAD.getSketch('sketch001').addPoint(CAD.Point(0, 0))
CAD.getSketch('sketch001').addPoint(CAD.Point(0, 1))
CAD.getSketch('sketch001').addPoint(CAD.Point(23.1, 1))
CAD.getSketch('sketch001').addPoint(CAD.Point(23.1, 40))
CAD.getSketch('sketch001').addPoint(CAD.Point(2.55, 40))
CAD.getSketch('sketch001').addPoint(CAD.Point(2.55, 41.8))
CAD.getSketch('sketch001').addPoint(CAD.Point(23.1, 41.8))
CAD.getSketch('sketch001').addPoint(CAD.Point(23.1, 57.6))
CAD.getSketch('sketch001').addPoint(CAD.Point(25.5, 57.6))
CAD.getSketch('sketch001').addPoint(CAD.Point(25.5, 57.1))
CAD.getSketch('sketch001').addPoint(CAD.Point(24.15, 57.1))
CAD.getSketch('sketch001').addPoint(CAD.Point(24.15, 0))
Model.updateSolverList()
Model.updateSolverList()
CAD.getObject('sketch001').label = 'fix1'
CAD.getSketch('sketch001').addLine(start = CAD.Point(0, 0), end = CAD.Point(0, 1), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.Start, geo_2='axis_x', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.End, geo_2='vertex2', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addLine(start = CAD.Point(0, 1), end = CAD.Point(23.1, 1), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line2', pos_1=PointPos.Start, geo_2='vertex2', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line2', pos_1=PointPos.End, geo_2='vertex3', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Horizontal, geo_1='line2')
CAD.getSketch('sketch001').addLine(start = CAD.Point(23.1, 1), end = CAD.Point(23.1, 40), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line3', pos_1=PointPos.Start, geo_2='vertex3', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line3', pos_1=PointPos.End, geo_2='vertex4', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Vertical, geo_1='line3')
CAD.getSketch('sketch001').addLine(start = CAD.Point(23.1, 40), end = CAD.Point(2.55, 40), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line4', pos_1=PointPos.Start, geo_2='vertex4', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line4', pos_1=PointPos.End, geo_2='vertex5', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Horizontal, geo_1='line4')
CAD.getSketch('sketch001').addLine(start = CAD.Point(2.55, 40), end = CAD.Point(2.55, 41.8), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line5', pos_1=PointPos.Start, geo_2='vertex5', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line5', pos_1=PointPos.End, geo_2='vertex6', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Vertical, geo_1='line5')
CAD.getSketch('sketch001').addLine(start = CAD.Point(2.55, 41.8), end = CAD.Point(23.1, 41.8), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line6', pos_1=PointPos.Start, geo_2='vertex6', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line6', pos_1=PointPos.End, geo_2='vertex7', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Horizontal, geo_1='line6')
CAD.getSketch('sketch001').addLine(start = CAD.Point(23.1, 41.8), end = CAD.Point(23.1, 57.6), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line7', pos_1=PointPos.Start, geo_2='vertex7', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line7', pos_1=PointPos.End, geo_2='vertex8', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Vertical, geo_1='line7')
CAD.getSketch('sketch001').addLine(start = CAD.Point(23.1, 57.6), end = CAD.Point(25.5, 57.6), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line8', pos_1=PointPos.Start, geo_2='vertex8', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line8', pos_1=PointPos.End, geo_2='vertex9', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addLine(start = CAD.Point(25.5, 57.6), end = CAD.Point(25.5, 57.1), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line9', pos_1=PointPos.Start, geo_2='vertex9', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line9', pos_1=PointPos.End, geo_2='vertex10', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addLine(start = CAD.Point(25.5, 57.1), end = CAD.Point(24.15, 57.1), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line10', pos_1=PointPos.Start, geo_2='vertex10', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line10', pos_1=PointPos.End, geo_2='vertex11', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addLine(start = CAD.Point(24.15, 57.1), end = CAD.Point(24.15, 0), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line11', pos_1=PointPos.Start, geo_2='vertex11', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line11', pos_1=PointPos.End, geo_2='vertex12', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Vertical, geo_1='line11')
CAD.getSketch('sketch001').addLine(start = CAD.Point(24.15, 0), end = CAD.Point(0, 0), construction = False)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line12', pos_1=PointPos.Start, geo_2='vertex12', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Coincident, geo_1='line12', pos_1=PointPos.End, geo_2='axis_x', pos_2=PointPos.Start)
CAD.getSketch('sketch001').addConstraint(type=ConstraintType.Horizontal, geo_1='line12')
CAD.recompute()

sketch = CAD.addSketch('sketch002')
sketch.setRotation(0, 0, 0, 1)
CAD.getSketch('sketch002').addPoint(CAD.Point(%R5%, 1))
CAD.getSketch('sketch002').addPoint(CAD.Point(%R5%, 23.4))
CAD.getSketch('sketch002').addPoint(CAD.Point(7, 23.4))
CAD.getSketch('sketch002').addPoint(CAD.Point(7, %X2%))
CAD.getSketch('sketch002').addPoint(CAD.Point(9, %X2%))
CAD.getSketch('sketch002').addPoint(CAD.Point(9, 2))
CAD.getSketch('sketch002').addPoint(CAD.Point(19, 2))
CAD.getSketch('sketch002').addPoint(CAD.Point(19, 1))
Model.updateSolverList()
Model.updateSolverList()
CAD.getObject('sketch002').label = 'fix2'
CAD.getSketch('sketch002').addLine(start = CAD.Point(%R5%, 1), end = CAD.Point(%R5%, 23.4), construction = False)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.Start, geo_2='vertex1', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.End, geo_2='vertex2', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Vertical, geo_1='line1')
CAD.getSketch('sketch002').addLine(start = CAD.Point(%R5%, 23.4), end = CAD.Point(7, 23.4), construction = False)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line2', pos_1=PointPos.Start, geo_2='vertex2', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line2', pos_1=PointPos.End, geo_2='vertex3', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addLine(start = CAD.Point(7, 23.4), end = CAD.Point(7, %X2%), construction = False)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line3', pos_1=PointPos.Start, geo_2='vertex3', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line3', pos_1=PointPos.End, geo_2='vertex4', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Vertical, geo_1='line3')
CAD.getSketch('sketch002').addLine(start = CAD.Point(7, %X2%), end = CAD.Point(9, %X2%), construction = False)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line4', pos_1=PointPos.Start, geo_2='vertex4', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line4', pos_1=PointPos.End, geo_2='vertex5', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addLine(start = CAD.Point(9, %X2%), end = CAD.Point(9, 2), construction = False)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line5', pos_1=PointPos.Start, geo_2='vertex5', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line5', pos_1=PointPos.End, geo_2='vertex6', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Vertical, geo_1='line5')
CAD.getSketch('sketch002').addLine(start = CAD.Point(9, 2), end = CAD.Point(19, 2), construction = False)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line6', pos_1=PointPos.Start, geo_2='vertex6', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line6', pos_1=PointPos.End, geo_2='vertex7', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Horizontal, geo_1='line6')
CAD.getSketch('sketch002').addLine(start = CAD.Point(19, 2), end = CAD.Point(19, 1), construction = False)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line7', pos_1=PointPos.Start, geo_2='vertex7', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line7', pos_1=PointPos.End, geo_2='vertex8', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addLine(start = CAD.Point(19, 1), end = CAD.Point(%R5%, 1), construction = False)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line8', pos_1=PointPos.Start, geo_2='vertex8', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Coincident, geo_1='line8', pos_1=PointPos.End, geo_2='vertex1', pos_2=PointPos.Start)
CAD.getSketch('sketch002').addConstraint(type=ConstraintType.Horizontal, geo_1='line8')
CAD.recompute()

sketch = CAD.addSketch('sketch003')
sketch.setRotation(0, 0, 0, 1)
CAD.getSketch('sketch003').addPoint(CAD.Point(%R4%, 22.4 +%DIST%))
CAD.getSketch('sketch003').addPoint(CAD.Point(%R4%, 27.7 +%DIST%))
CAD.getSketch('sketch003').addPoint(CAD.Point(%R2%, 27.7 +%DIST%))
CAD.getSketch('sketch003').addPoint(CAD.Point(%R2%, 22.4 +%DIST%+%X1%))
CAD.getSketch('sketch003').addPoint(CAD.Point(5.5, 22.4 +%DIST%+%X1%))
CAD.getSketch('sketch003').addPoint(CAD.Point(5.5, 35 +%DIST%))
CAD.getSketch('sketch003').addPoint(CAD.Point(%R1%, 35 +%DIST%))
CAD.getSketch('sketch003').addPoint(CAD.Point(%R1%, %X2% +%DIST%))
CAD.getSketch('sketch003').addPoint(CAD.Point(%R3%, %X2% +%DIST%))
CAD.getSketch('sketch003').addPoint(CAD.Point(%R3%, 22.4 +%DIST%))
Model.updateSolverList()
Model.updateSolverList()
CAD.getObject('sketch003').label = 'armature'
CAD.getSketch('sketch003').addLine(start = CAD.Point(%R4%, 22.4 +%DIST%), end = CAD.Point(%R4%, 27.7 +%DIST%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.Start, geo_2='vertex1', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.End, geo_2='vertex2', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Vertical, geo_1='line1')
CAD.getSketch('sketch003').addLine(start = CAD.Point(%R4%, 27.7 +%DIST%), end = CAD.Point(%R2%, 27.7 +%DIST%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line2', pos_1=PointPos.Start, geo_2='vertex2', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line2', pos_1=PointPos.End, geo_2='vertex3', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Horizontal, geo_1='line2')
CAD.getSketch('sketch003').addLine(start = CAD.Point(%R2%, 27.7 +%DIST%), end = CAD.Point(%R2%, 22.4 +%DIST%+%X1%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line3', pos_1=PointPos.Start, geo_2='vertex3', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line3', pos_1=PointPos.End, geo_2='vertex4', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Vertical, geo_1='line3')
CAD.getSketch('sketch003').addLine(start = CAD.Point(%R2%, 22.4 +%DIST%+%X1%), end = CAD.Point(5.5, 22.4 +%DIST%+%X1%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line4', pos_1=PointPos.Start, geo_2='vertex4', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line4', pos_1=PointPos.End, geo_2='vertex5', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Horizontal, geo_1='line4')
CAD.getSketch('sketch003').addLine(start = CAD.Point(5.5, 22.4 +%DIST%+%X1%), end = CAD.Point(5.5, 35 +%DIST%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line5', pos_1=PointPos.Start, geo_2='vertex5', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line5', pos_1=PointPos.End, geo_2='vertex6', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addLine(start = CAD.Point(5.5, 35 +%DIST%), end = CAD.Point(%R1%, 35 +%DIST%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line6', pos_1=PointPos.Start, geo_2='vertex6', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line6', pos_1=PointPos.End, geo_2='vertex7', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Horizontal, geo_1='line6')
CAD.getSketch('sketch003').addLine(start = CAD.Point(%R1%, 35 +%DIST%), end = CAD.Point(%R1%, %X2% +%DIST%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line7', pos_1=PointPos.Start, geo_2='vertex7', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line7', pos_1=PointPos.End, geo_2='vertex8', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addLine(start = CAD.Point(%R1%, %X2% +%DIST%), end = CAD.Point(%R3%, %X2% +%DIST%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line8', pos_1=PointPos.Start, geo_2='vertex8', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line8', pos_1=PointPos.End, geo_2='vertex9', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Horizontal, geo_1='line8')
CAD.getSketch('sketch003').addLine(start = CAD.Point(%R3%, %X2% +%DIST%), end = CAD.Point(%R3%, 22.4 +%DIST%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line9', pos_1=PointPos.Start, geo_2='vertex9', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line9', pos_1=PointPos.End, geo_2='vertex10', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Vertical, geo_1='line9')
CAD.getSketch('sketch003').addLine(start = CAD.Point(%R3%, 22.4 +%DIST%), end = CAD.Point(%R4%, 22.4 +%DIST%), construction = False)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line10', pos_1=PointPos.Start, geo_2='vertex10', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Coincident, geo_1='line10', pos_1=PointPos.End, geo_2='vertex1', pos_2=PointPos.Start)
CAD.getSketch('sketch003').addConstraint(type=ConstraintType.Horizontal, geo_1='line10')
CAD.recompute()

Face=CAD.addCreateFacebySketch('Face')
Face.sketch = 'sketch'
CAD.getObject('sketch').setHide(True)
Window.setView('fitView')
Face=CAD.addCreateFacebySketch('Face001')
Face.sketch = 'sketch001'
CAD.getObject('sketch001').setHide(True)
Window.setView('fitView')
Face=CAD.addCreateFacebySketch('Face002')
Face.sketch = 'sketch002'
CAD.getObject('sketch002').setHide(True)
Window.setView('fitView')
Face=CAD.addCreateFacebySketch('Face003')
Face.sketch = 'sketch003'
CAD.getObject('sketch003').setHide(True)
Window.setView('fitView')

sketch = CAD.addSketch('sketch004')
sketch.setRotation(0, 0, 0, 1)
CAD.getSketch('sketch004').addCircleArc(center = CAD.Point(0, 20), range = CAD.Point(-1.5708,1.5708), radius = 80)
CAD.getSketch('sketch004').addConstraint(type=ConstraintType.PointOnObject, geo_1='arc1', pos_1=PointPos.Mid, geo_2='axis_y')
CAD.getSketch('sketch004').addConstraint(type=ConstraintType.PointOnObject, geo_1='arc1', pos_1=PointPos.End, geo_2='axis_y')
CAD.getSketch('sketch004').addConstraint(type=ConstraintType.PointOnObject, geo_1='arc1', pos_1=PointPos.Start, geo_2='axis_y')
CAD.getSketch('sketch004').addLine(start = CAD.Point(0, -60), end = CAD.Point(0, 100), construction = False)
CAD.getSketch('sketch004').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.Start, geo_2='arc1', pos_2=PointPos.Start)
CAD.getSketch('sketch004').addConstraint(type=ConstraintType.Coincident, geo_1='line1', pos_1=PointPos.End, geo_2='arc1', pos_2=PointPos.End)
CAD.getSketch('sketch004').addConstraint(type=ConstraintType.Vertical, geo_1='line1')
CAD.recompute()
Face=CAD.addCreateFacebySketch('Face004')
Face.sketch = 'sketch004'
CAD.getObject('sketch004').setHide(True)
Window.setView('fitView')

Model.updateSolverList()
Model.updateSolverList()
geomList = [['Face004', []]]
Mesh.createPartsComponent(comp_name = 'air', geomNamelist = geomList)
geomList = [['Face003', []]]
Mesh.createPartsComponent(comp_name = 'armature', geomNamelist = geomList)
geomList = [['Face001', []], ['Face002', []]]
Mesh.createPartsComponent(comp_name = 'fix', geomNamelist = geomList)
geomList = [['Face', []]]
Mesh.createPartsComponent(comp_name = 'coil', geomNamelist = geomList)
geomList = [['Face004', ['Edge1']]]
Mesh.createPartsComponent(comp_name = 'bnd1', geomNamelist = geomList)
geomList = [['Face004', ['Edge2']]]
Mesh.createPartsComponent(comp_name = 'bnd2', geomNamelist = geomList)


gl.Table('dt4e')
table = gl.tables['dt4e']
table.interpolationType = InterpolationType.Linear
table.extrapolationType = ExtrapolationType.BHType1
table.argument = 'H'
table.outPutName = 'B'
table.setData( ( 0, 100, 201, 315, 401, 530, 645, 703, 817, 903, 1000, 2040, 3110, 4060, 5100, 6190, 7080, 8000, 80000, 800000, ), ( 0, 0.122, 0.402, 0.821, 1.03, 1.19, 1.3, 1.33, 1.39, 1.42, 1.46, 1.63, 1.7, 1.74, 1.78, 1.81, 1.83, 1.85, 1.851, 1.852, ) ) 

gl.Material('air')
gl.materials['air'].addType(MaterialType.Viscosity)
gl.materials['air'].setValue(MaterialProperty.Mu, ValueType.Value,  1.7894e-08)
gl.materials['air'].addType(MaterialType.BModulus)
gl.materials['air'].setValue(MaterialProperty.Bulk, ValueType.Value,  20000000)
gl.materials['air'].addType(MaterialType.Thermal)
gl.materials['air'].setValue(MaterialProperty.KZZ, ValueType.Value,  26.24)
gl.materials['air'].setValue(MaterialProperty.KYY, ValueType.Value,  26.24)
gl.materials['air'].setValue(MaterialProperty.KXX, ValueType.Value,  26.24)
gl.materials['air'].setValue(MaterialProperty.HCAPACITY, ValueType.Value,  1012000000)
gl.materials['air'].addType(MaterialType.Magnetic_MUR)
gl.materials['air'].setValue(MaterialProperty.MURX, ValueType.Value,  1)
gl.materials['air'].setValue(MaterialProperty.MURY, ValueType.Value,  1)
gl.materials['air'].setValue(MaterialProperty.MURZ, ValueType.Value,  1)
gl.materials['air'].setValue(MaterialProperty.Density, ValueType.Value,  1.225e-09)
gl.Material('dt4e')
gl.materials['dt4e'].addType(MaterialType.Magnetic_MUR)
gl.materials['dt4e'].setValue(MaterialProperty.MURX, ValueType.Table,  1)
gl.materials['dt4e'].setValue(MaterialProperty.MURY, ValueType.Table,  1)
gl.materials['dt4e'].setValue(MaterialProperty.MURZ, ValueType.Table,  1)
gl.materials['dt4e'].setValue(MaterialProperty.Density, ValueType.Value,  2e-07)
gl.materials['dt4e'].removeType(MaterialType.IronLoss)
gl.materials['dt4e'].value(MaterialProperty.Density).value = 2e-07
gl.materials['dt4e'].addType(MaterialType.Thermal)
gl.materials['dt4e'].setValue(MaterialProperty.KZZ, ValueType.Value,  20000)
gl.materials['dt4e'].setValue(MaterialProperty.KYY, ValueType.Value,  20000)
gl.materials['dt4e'].setValue(MaterialProperty.KXX, ValueType.Value,  20000)
gl.materials['dt4e'].setValue(MaterialProperty.HCAPACITY, ValueType.Value,  460000000)
gl.materials['dt4e'].setValue(MaterialProperty.Density, ValueType.Value,  7.5e-06)
gl.Material('coil')
gl.materials['coil'].addType(MaterialType.Thermal)
gl.materials['coil'].setValue(MaterialProperty.KZZ, ValueType.Value,  380000)
gl.materials['coil'].setValue(MaterialProperty.KYY, ValueType.Value,  380000)
gl.materials['coil'].setValue(MaterialProperty.KXX, ValueType.Value,  380000)
gl.materials['coil'].setValue(MaterialProperty.HCAPACITY, ValueType.Value,  380000000)
gl.materials['coil'].addType(MaterialType.Electro_RSV)
gl.materials['coil'].setValue(MaterialProperty.RSVZ, ValueType.Value,  0.00019025)
gl.materials['coil'].setValue(MaterialProperty.RSVY, ValueType.Value,  0.00019025)
gl.materials['coil'].setValue(MaterialProperty.RSVX, ValueType.Value,  0.00019025)
gl.materials['coil'].addType(MaterialType.Magnetic_MUR)
gl.materials['coil'].setValue(MaterialProperty.MURX, ValueType.Value,  1)
gl.materials['coil'].setValue(MaterialProperty.MURY, ValueType.Value,  1)
gl.materials['coil'].setValue(MaterialProperty.MURZ, ValueType.Value,  1)
gl.materials['coil'].setValue(MaterialProperty.Density, ValueType.Value,  8.95e-06)
Model.updateSolverList()
Model.updateSolverList()

Model.Model('model_1')
Model.models['model_1'].typeName = 'Electromagnetic (LF)'
Model.models['model_1'].solution.setValue(SolutionType.GaugeMethod, 3)
Model.models['model_1'].importComponent('air')
Model.models['model_1'].importComponent('armature')
Model.models['model_1'].importComponent('fix')
Model.models['model_1'].importComponent('coil')
Model.models['model_1'].importComponent('bnd1')
Model.models['model_1'].importComponent('bnd2')
component = Model.models['model_1'].componentList.at(0)
component.elementType = 'MAGNETIC_Tri3'
component.elementAttribute = 'Axisymmetric'
component.thickness = 1
component.emagForceOutput = 1
component.emagForceCalculation = 2
Mesh.setComponentToElemType('air')
component = Model.models['model_1'].componentList.at(1)
component.elementType = 'MAGNETIC_Tri3'
component.elementAttribute = 'Axisymmetric'
component.thickness = 1
component.emagForceOutput = 1
component.emagForceCalculation = 2
Mesh.setComponentToElemType('armature')
component = Model.models['model_1'].componentList.at(2)
component.elementType = 'MAGNETIC_Tri3'
component.elementAttribute = 'Axisymmetric'
component.thickness = 1
component.emagForceOutput = 1
component.emagForceCalculation = 2
Mesh.setComponentToElemType('fix')
component = Model.models['model_1'].componentList.at(3)
component.elementType = 'MAGNETIC_Tri3'
component.elementAttribute = 'Axisymmetric'
component.thickness = 1
component.emagForceOutput = 1
component.emagForceCalculation = 2
Mesh.setComponentToElemType('coil')
Model.models['model_1'].componentList.at(0).materialId = 1
Model.models['model_1'].componentList.at(1).materialId = 2
Model.models['model_1'].componentList.at(2).materialId = 2
Model.models['model_1'].componentList.at(3).materialId = 3
bc = Model.BoundaryCondition()
bc.type = 'SourceCurrentDensity'
bc.compId = 4
bc.value('JSX').value = 0
bc.value('JSX').type = ValueType.Value
bc.value('JSY').value = 0
bc.value('JSY').type = ValueType.Value
bc.value('JSZ').value = 3418.604651
bc.value('JSZ').type = ValueType.Value
Model.models['model_1'].bcList.append(bc)
Model.updateSolverList()
Model.updateSolverList()

bc = Model.BoundaryCondition()
bc.type = 'MagneticFluxParallel'
bc.compId = 5
bc.value('AZ').value = 0
bc.value('AZ').type = ValueType.Value
bc.value('EmagLM').value = 0
bc.value('EmagLM').type = ValueType.Value
Model.models['model_1'].bcList.append(bc)
bc = Model.BoundaryCondition()
bc.type = 'MagneticFluxParallel'
bc.compId = 6
bc.value('AZ').value = 0
bc.value('AZ').type = ValueType.Value
bc.value('EmagLM').value = 0
bc.value('EmagLM').type = ValueType.Value
Model.models['model_1'].bcList.append(bc)


Mesh.editGlobalMeshSize(id = 1, MeshSize = '2.00')
Mesh.setLocalSeed(part = 'Face003', sub_list = ['Edge10', 'Edge9', 'Edge8', 'Edge7', 'Edge6', 'Edge4', 'Edge3', 'Edge2', 'Edge1'], size = 0.5)
Mesh.setLocalSeed(part = 'Face002', sub_list = ['Edge3', 'Edge4', 'Edge6', 'Edge7', 'Edge5', 'Edge1'], size = 0.5)
Mesh.setLocalSeed(part = 'Face001', sub_list = ['Edge3', 'Edge10', 'Vertex9', 'Edge8', 'Edge7', 'Edge11', 'Edge2', 'Edge12', 'Edge4', 'Edge5', 'Edge6'], size = 0.5)
Mesh.setLocalSeed(part = 'Face', sub_list = ['Edge2', 'Edge1', 'Edge3', 'Edge4'], size = 0.5)
Mesh.createSharedTopoMesh(listFullName = ['Face.Face1', 'Face001.Face1', 'Face002.Face1', 'Face003.Face1', 'Face004.Face1'], sharedTopoMeshType = 2, elemType = 'ETri', order = 1, tolerance = 0.000000000)
Model.updateSolverList()
Window.setView('topview')

para = Model.OutputPara()
para.name = 'parameter_1'
para.timeType = 'Latest'
para.locationType = 'Integration'
para.idType = 'comp'
para.variable = 'EMAGFY'
para.locationId = 2
para.endTime = 1
para.startTime = 0
Model.models['model_1'].outputParaList.append(para)

simulation = Model.models['model_1'].simulation
simulation.isDoNewRun = 1
simulation.restartStep = 0
simulation.maxCouplingIterNum = 100
simulation.isThermalFluid = 0
del simulation

#优化
para = Model.DesignOptParameter()
para.name = 'R1' 
para.setProperty( DesignOptType.Type, 1 )
Model.designOptParameters.append( para )
para = Model.DesignOptParameter()
para.name = 'R5' 
para.setProperty( DesignOptType.Type, 1 )
Model.designOptParameters.append( para )



Model.models['model_1'].outputParaList.append(para)
input_para = Model.designOptParameters.at(0)

input_para.setProperty( DesignOptType.Nature, 1 )
input_para.setProperty( DesignOptType.LowerBound, 7 )
input_para.setProperty( DesignOptType.UpperBound, 9 )
input_para = Model.designOptParameters.at(1)
input_para.setProperty( DesignOptType.Nature, 1 )
input_para.setProperty( DesignOptType.LowerBound, 6 )
input_para.setProperty( DesignOptType.UpperBound, 7 )

para.name = 'parameter_1' 
para.setProperty( DesignOptType.Type, 2 )
Model.designOptParameters.append( para )
output_para = Model.designOptParameters.at(2)
output_para.setProperty( DesignOptType.Goal, 2 )
output_para.setProperty( DesignOptType.Nature, 3 )